package androidx.preference;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class a extends f {
    private EditText x;
    private CharSequence y;

    private EditTextPreference s() {
        return (EditTextPreference) l();
    }

    public static a t(String str) {
        a aVar = new a();
        Bundle bundle = new Bundle(1);
        bundle.putString("key", str);
        aVar.setArguments(bundle);
        return aVar;
    }

    /* access modifiers changed from: protected */
    public boolean m() {
        return true;
    }

    /* access modifiers changed from: protected */
    public void n(View view) {
        super.n(view);
        EditText editText = (EditText) view.findViewById(16908291);
        this.x = editText;
        if (editText != null) {
            editText.requestFocus();
            this.x.setText(this.y);
            EditText editText2 = this.x;
            editText2.setSelection(editText2.getText().length());
            if (s().L0() != null) {
                s().L0().a(this.x);
                return;
            }
            return;
        }
        throw new IllegalStateException("Dialog view must contain an EditText with id @android:id/edit");
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.y = bundle == null ? s().M0() : bundle.getCharSequence("EditTextPreferenceDialogFragment.text");
    }

    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putCharSequence("EditTextPreferenceDialogFragment.text", this.y);
    }

    public void p(boolean z) {
        if (z) {
            String obj = this.x.getText().toString();
            EditTextPreference s = s();
            if (s.b(obj)) {
                s.N0(obj);
            }
        }
    }
}
